<?php

/***  DOCUMENTATION LAYER

Ceo Module Unit Test

Last Update: Sep 2007
  
DESCRIPTION
  This file provides a simple example of how module function in the CEO framework.
  
NOTES
  Modules are basically sub-scripts of the main CEO script.  The are loaded
  using the load_mod($path, $ARG) method, though they could just as easily
  be called directly using require() or include().
  
  There are standards, but they are not really that strictly enforced.  The best
  insight into the module structure and protocol is to look at the load_mod method
  in the CeoFramework class (framework.class.php).  In brief, a module file
  should return an array ($_MOD['Return']) with these three values:
  
    $_MOD['Return'][0] : string - for display in browser    
    $_MOD['Return'][1] : boolean (0/1) - successful/without exception?
    $_MOD['Return'][2] : assoc. array - data (as a side-effect)
    
  which is the returned to the main script.

  See the module_scope unit test in the Repository for an illustration of how
  modules are scoped.
    
______________________________________________________________________________*/

$_tx0 = microtime();
$test_root = ( strpos(dirname(__FILE__), 'repository') === false ) ? '' : '../';


// Test Name
$test_name = 'module example';

// Include Files
require_once($test_root . '../php_ceo/framework.class.php');

// Configure Test
$debug = 1;


// *** Test Procedure
// Load Ceo Framework
$Ceo = new CeoFramework($debug);

// Set Module Arguments
$_ARG = array
(
  'The values in this array will be available to the module.  The following values are the recommended return values:',
  '$_MOD[Return][0] : string - for display in browser',
  '$_MOD[Return][1] : boolean (0/1) - successful/without exception?',
  '$_MOD[Return][2] : assoc. array - data (as a side-effect)',
);

// Load Module
$_MOD['RET'] = $Ceo->load_mod('_tpl.mod.php', $_ARG);

// Output Module Results
print "<div style='font-family:sans-serif; font-size:12px; border:8px solid #eee; padding:1em;'>{$_MOD['RET'][0]}</div>";
print "<div style='margin:16px 0 0; font-family:sans-serif; font-size:12px; border:8px solid #eef; padding:1em;'><h3>\$_MOD[RET] dump:</h3>" . $Ceo->print_r($_MOD['RET']) . "</div>";




// Footer
$_txn = microtime();
$stx = number_format(((substr($_txn,0,9)) + (substr($_txn,-10)) - (substr($_tx0,0,9)) - (substr($_tx0,-10))),4); 
echo "<h6>test '$test_name' complete in $stx s</h6>";
?>
